﻿@{
    ViewBag.Title = "Role";
    Layout = "~/Views/Shared/_WindowSmall.cshtml";
}
@model Webdiyer.WebControls.Mvc.PagedList<OneStationFile.Model.Role>
    @using Webdiyer.WebControls.Mvc;
    <div id="page-wrapper1">
        <div class="row">
            <h3 class="page-header">用户管理-角色</h3>

            <!-- /.col-lg-12 -->
        </div>
        <!-- /.row -->
        <!-- /.row -->
        <div class="row">

            <!-- /.col-lg-6 -->
            <div class="col-lg-12">
                <div class="panel panel-default">
                    <!-- /.panel-heading -->
                    <div class="panel-body">
                        <div class="table-responsive">
                            <table class="table">
                                <thead>
                                    <tr>
                                        <th>#</th>
                                        <th>名称</th>
                                        <th>描述</th>
                                        <th><button class="btn btn-primary  btn-xs" ><i class="fa fa-circle "></i></button></th>
                                    </tr>
                                </thead>
                                <tbody>
                                    @{ int i = 0;
                                        OneStationFile.Model.Role viewRole = (OneStationFile.Model.Role)ViewBag.usersRole;
                                        }
                                    @foreach (var item in Model)
                                    {
                                        string viewChecked = "";
                                        if (item == viewRole)
                                        {
                                            viewChecked = "checked";
                                        }
                                    <tr class="success">
                                        <td>@(++i)</td>
                                        <td>
                                           @item.Name
                                        </td>
                                        <td>@item.Describe</td>
                                        <td>
                                            <input type="radio"  name="radioRole"  @viewChecked value="@item.Id" />
                                        </td>
                                    </tr>
                                    }






                                </tbody>
                            </table>
                            @Html.Pager(Model, new PagerOptions { PageIndexParameterName = "page", NumericPagerItemCount = 5, ContainerTagName = "ul", CssClass = "pagination", CurrentPagerItemTemplate = "<li class=\"active\"><a href=\"#\">{0}</a></li>", DisabledPagerItemTemplate = "<li class=\"disabled\"><a>{0}</a></li>", PagerItemTemplate = "<li>{0}</li>", Id = "pager2", PageIndexBoxId = "pageIndexBox", GoToButtonId = "goToBtn", NavigationPagerItemsPosition = PagerItemsPosition.Left })
                        </div>
                        <button type="button" onclick="AddRoles();" class="btn btn-default">提交</button>
                        <button type="button" onclick="art.dialog.close();" class="btn btn-default">取消</button>
                        <!-- /.table-responsive -->
                    </div>
                    <!-- /.panel-body -->
                </div>
                <!-- /.panel -->
            </div>
            <!-- /.col-lg-6 -->
        </div>
        <!-- /.row -->
    </div>


    @section scripts{
    <script>
       
        //批量添加节点
        function AddRoles(id) {
            art.dialog.confirm('你确定要添加所选中的信息吗？', function () {
                var roleId = $('input[name="radioRole"]:checked').val();
                $.post("/Users/AddRole", { roleId: roleId,id:@Request["id"] }, function (result) {
                    art.dialog.tips(result.msg);
                    if (result.res == true) {
                        var win = art.dialog.open.origin;//来源页面
                        // 如果父页面重载或者关闭其子对话框全部会关闭
                        setTimeout(function () { win.location.reload();; }, 1000);
                    }
                }, "json");
            }, function () {
                art.dialog.tips('用户取消了操作');
            });

        }
        //end
    </script>
    }

